<?php 

	$host = "localhost"; 
	$user = "root"; 
	$pass = ""; 
	$database = "atpchat"; 
	$linkID = new PDO("mysql:host=".$host.";dbname=".$database, $user, $pass);
	$utilisateur=$_POST['utilisateur'];
	$msg=$_POST['msg'];
	$sth = $linkID->prepare("SELECT iduser FROM user where login=:name");
					$sth->execute(array(':name'=>$utilisateur));
					while ($r = $sth->fetch(PDO::FETCH_OBJ)) {
						foreach ($r as $colonne){
							$result = $colonne;
						}
					}
	$stp=$linkID->prepare("INSERT INTO chat(idmessage, utilisateur, message) VALUES(null, :name,:msg)");
	$stp->execute(array(':name'=>$result, ':msg'=>$msg));
	
	
?>

